<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="renderer" content="webkit" />
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<meta name="App-Config" content="fullscreen=yes,useHistoryState=yes,transition=yes" />
		<meta content="yes" name="apple-mobile-web-app-capable" />
		<meta content="yes" name="apple-touch-fullscreen" />
		<meta content="telephone=no,email=no" name=format-detection />
		<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>机构</title>
		<link href="../c/mechanism.css" rel="stylesheet" type="text/css">

	</head>

	<body>
		<div id="main">
			<div class="user">
				<p class="user_pic"><img src="../i/touxiang.png"></p>
				<p class="username">
					<span style="display: block;width: 50%;float: left;height: 1rem; overflow: hidden;height: 1.5rem;">
					</span>
					<span style="    display: block;float: left;height: 1rem;">
						<!-- 一星达人 --></span>
				</p>
				<p class="user_time">
					加入时间:
				</p>
				<div class="addpis">
					<p class="yuea">
						余额:
					</P>
					<p class="xfjs">直播消费金:</p>
					<p class="sr" style="display: none;">预计收入: </p>
					<P class="lwdsj"style="text-align: left;float: left;">礼物打赏金:</P>
				</div>
				<p class="yub">
					<span class="yubs" style="overflow: auto;"><small style="display: block;float: left;width: 50%;font-size: 1rem;">愉币:</small><small
						 style="display: block;float: left;width: 50%;font-size: 1rem;display: none;">本月食宿费:</small></span>
				</p>
			</div>
			<div class="gh">
				<p class="ajaxtet"><img src="http://qiniu.live.kxg99.com/yuzhibo/addpic/darentb.png"><span></span></p>
				<p class="sjka"></p>
				<p class="tbnsj">立即升级<img src="http://qiniu.live.kxg99.com/yuzhibo/addpic/lefts.png" style="width: 0.6rem;margin-left: 0.2rem;" /></p>
				<!-- <p class="tbnsj tella" style="display: none;">立即升级2<img src="../i/addpic/lefts.png" style="width: 0.6rem;margin-left: 0.2rem;" /></p> -->
			</div>
			<p class="tiitle cl mla">
				<img src="http://qiniu.live.kxg99.com/yuzhibo/addpic/as.png" />
				<span>工会专属任务</span>
				<img src="http://qiniu.live.kxg99.com/yuzhibo/addpic/as.png" />
			</p>
			<div class="darena" style="margin-bottom:0.875rem;">
				<p>今日任务进度</p>
				<p>当前已完成<span></span></p>
				<div class="bgsa">
					<p class="jindut"></p>
				</div>
				<a onclick="_url({url:'new_renwu',title:'任务中心'})">去做任务</a>
			</div>
			<div class="adduser cl">
				<p class="adduser_tit " style="ba"><span>工会成员</span><span>
						<!-- 工会可以帮助五名会员免费升为达人 --></span></p>
				<div class="adduser_list">
					<!-- <div class="adduser_div uls">
					<p class="mls"></p>
					<p>测试1</p> 
					<p>达人</p>
				</div>
				<div class="adduser_div kols">
					<p class="addus"></p>
					<p>待添加</p>
					<p>达人</p>
				</div> -->
				</div>
				<button class="adduserbtn cl" onclick="_url({url:'adduser',title:'添加成员'})">添加成员</button>

			</div>
		</div>
		<div class="bottomnav">
			<a onclick="_url({url:'recommend',title:'推荐数量'})">
				<p><img src="http://qiniu.live.kxg99.com/yuzhibo/addpic/tjsl.png"><span>推荐数量</span></p>
			</a>
			<a onclick="_url({url:'detailed',title:'愉币明细'})">
				<!-- href="detailed.html" -->
				<p><img src="http://qiniu.live.kxg99.com/yuzhibo/addpic/ybmx.png"><span>愉币明细</span></p>
			</a>
			<a onclick="_url({url:'withdrawal',title:'提现'})">
				<p><img src="http://qiniu.live.kxg99.com/yuzhibo/addpic/tx.png"><span>提现</span></p>
			</a>
			<a onclick="_url({url:'course',title:'课程介绍'})">
				<p><img src="http://qiniu.live.kxg99.com/yuzhibo/addpic/kc.png"><span>课程介绍</span></p>
			</a>
			<a onclick="_url({url:'renwu_histy',title:'任务记录'})">
				<p><img src="../i/renwu.jpg" style="border-radius: 50%;margin-top: 0.5rem;"><span>任务记录</span></p>
			</a>
			<!-- <a onclick="_url({url:'withdrawalb',title:'渝币转出'})">
				<p><img src="../i/renwu.jpg" style="border-radius: 50%;margin-top: 0.5rem;"><span>渝币转出</span></p>
			</a> -->
		</div>
		<div class="tcsja tenkls" style="display: none;">
			<div class="mains">
				<p class="mainsa_tit">立即升级</p>
				<p class="payfsw" name="a"><img src="http://qiniu.live.kxg99.com/yuzhibo/addpic/hei.png"><span>工会</span><small><img
						 src="http://qiniu.live.kxg99.com/yuzhibo/addpic/g.png"></small></p>
				<p class="payfsw" name="a"><img src="http://qiniu.live.kxg99.com/yuzhibo/addpic/hei.png"><span>机构</span><small><img
						 src="http://qiniu.live.kxg99.com/yuzhibo/addpic/g.png"></small></p>
				<p class="btnsure">立即升级</p>
				<p class="closebtn">关闭弹窗</p>
			</div>
		</div>
		<div class="tcsja tle" style="display: none;">
			<div class="mains">
				<p style="height: 2rem;text-align: center;font-size: 1.2rem;line-height: 2rem;padding-top: 1rem;">升级请联系客服:400-766-5818</p>
				<p style="height: 2rem;text-align: center;font-size: 1.2rem;line-height: 2rem;padding-bottom: 1rem;"><a href="tel:400-766-5818">点击拨打</a></p>
				<p style="width: 30%;height: 2rem;text-align: center;background: #2CB6FE;color: #fff;margin: 1rem 0;margin-left: 35%;border-radius: 5px;line-height: 2rem;"
				 class="close">关闭</p>
			</div>
		</div>
	</body>
</html>
</body>
</html>
<script src="../j/api.js"></script>
<script src="../j/jquery-3.3.1.min.js"></script>
<script>
	function urlsa() {
		var imglen = $("img").length;
		var picurls = picurl + "/addpic";
		for (var i = 0; i < imglen; i++) {
			var tpl = $("img").eq(i).attr("src");
			tpls = tpl.replace("../i/addpic", picurls);
			$("img").eq(i).attr("src", tpls);
		}
	}
	apiready = function() {
		// $(".yuba").on("click",function(){
		// 	window.open("detailed.html");
		// })
		var _user = _getPrefs("_user");
		urlsa();
		//获取链接传值，判断显示样式
		var jb = localStorage.getItem("jbtoday");
		var agent;
		_ajax1("task/toDayCountUser", function(ret, err) {
			if (ret) {
				var usernum = ret.ret.toDayCountUser;
				var xtnum = ret.ret.toDayCount;
				var bfb = usernum / xtnum;
				if (bfb >= 1) {
					$(".darena p span").text("100%");
					$(".jindut").css("width", "100%");
				} else {
					$(".darena p span").text("" + ((usernum * 10) / ((xtnum) * 10)) * 1000 / 10 + "%");
					$(".jindut").css("width", (usernum / (xtnum)) * 100 + "%");

				}
			}
		})
		_ajax1("agent/index", function(ret, err) {
			if (ret) {
				if (ret.ret.img == null || ret.ret.img == "null") {

				} else {
					$(".user_pic img").attr("src", _img(ret.ret.img));
				}
				$(".username span").eq(0).text(ret.ret.nickname);
				$(".yubs small").eq(0).text("愉币(累计收入):" + ret.ret.total_rebate + "");
				$(".user_time").text("加入时间:" + ret.ret.agent_date + "");
				$(".yuea").text("余额:" + ret.ret.balance + "");
				$(".xfjs").text("直播消费金:" + ret.ret.charge_live + "");
				$(".lwdsj").text("礼物打赏金:" + ret.ret.charge_liwu + "");
				$(".sr").text("预计收入:" + ret.ret.may_rebate + "")
				if (ret.ret.is_invite == "2" && ret.ret.levels == 0) {
					$(".tbnsj").addClass("tella");
				} else {
					$(".tbnsj").addClass("tell");
					// $(".tbnsj").addClass("tella");
				}
				//判断经纪人类型
				agent = ret.ret.levels;
				if (ret.ret.levels == 0 || ret.ret.levels == "0") {
					$(".username span").eq(1).text("达人");
				} else if (ret.ret.levels == 1 || ret.ret.levels == "1") {
					$(".username span").eq(1).text("工会");
				} else if (ret.ret.levels == 2 || ret.ret.levels == "2") {
					$(".username span").eq(1).text("机构");
					$(".yubs small").eq(1).show();
					$(".yubs small").eq(1).text("本月食宿费:" + ret.ret.fee);
				}
				//判断分钱级别
				if (ret.ret.levels == 0 || ret.ret.levels == "0") {
					$(".ajaxtet span").text("达人");
					$(".sjka").html("升级工会/机构<br/>招募更多达人更多收益");
				} else if (ret.ret.is_agent == "1" && ret.ret.levels == "1") {
					$(".cl").css("display", "block");
					$(".ajaxtet span").text("工会");
					$(".mla span").text("工会专属任务");
					$(".adduser_tit span").eq(0).text("工会成员");
					$(".adduser_tit span").eq(1).text("工会可以帮助三名会员免费升为达人");
					$(".sjka").html("升级机构<br/>招募更多达人更多收益");
					if (ret.ret.list) {
						var str = '';
						var tpl = '';
						if (ret.ret.list.length > 0 && ret.ret.list.length <= 3) {
							for (var i = 0; i < ret.ret.list.length; i++) {
								str += '<div class="adduser_div uls">';
								str += ' <p class="addus" style="overflow: hidden;">';
								if (ret.ret.list[i].img == null || ret.ret.list[i].img == "null") {
									str += '<img src="' + picurl + 'redian-img-zan.png"style="width:100%;height:100%;"></p>';
								} else {
									str += '<img src="' + _img(ret.ret.list[i].img) + '"style="width:100%;height:100%;"></p>';
								}
								str += '<p>' + beautySub(ret.ret.list[i].nickname, 2) + '</p>';
								str += '<p>';
								if (ret.ret.list[i].levels == 0 && ret.ret.list[i].agent == 0) {
									str += "普通";
								} else if (ret.ret.list[i].agent == 1 && ret.ret.list[i].levels == 0) {
									str += "达人";
								} else if (ret.ret.list[i].agent == 1 && ret.ret.list[i].levels == 1) {
									str += "工会";
								} else if (ret.ret.list[i].agent == 1 && ret.ret.list[i].levels == 2) {
									str += "机构";
								}
								str += '</p>';
								str += '</div>';
							}
							for (var j = 0; j < (3 - (ret.ret.list.length)); j++) {
								tpl += '<div class="adduser_div kols">';
								tpl += '<p class="addus"></p>';
								tpl += '<p>待添加</p>';
								tpl += '<p>达人</p>';
								tpl += '</div>';
							}
							str = str + tpl;
							$(".adduser_list").html(str);
						} else {
							for (var j = 0; j < 3; j++) {
								tpl += '<div class="adduser_div kols">';
								tpl += '<p class="addus"></p>';
								tpl += '<p>待添加</p>';
								tpl += '<p>达人</p>';
								tpl += '</div>';
							}
							str = str + tpl;
							$(".adduser_list").html(str);
						}
					}
				} else if (ret.ret.is_agent == "1" && ret.ret.levels == "2") {
					$(".cl").css("display", "block");
					$(".ajaxtet span").text("机构");
					$(".mla span").text("机构专属任务");
					$(".adduser_tit span").eq(0).text("机构成员");
					$(".adduser_tit span").eq(1).text("机构可以帮助十名会员免费升为达人");
					$(".sjka").text("招募更多达人更多收益");
					$(".gh p").eq(2).css("width", "40%");
					$(".gh p").eq(2).css("text-align", "right");
					$(".tbnsj").css("display", "none");
					if (ret.ret.list) {
						if (ret.ret.list.length > 0 && ret.ret.list.length <= 10) {
							var str = '';
							var tpl = '';
							for (var i = 0; i < ret.ret.list.length; i++) {
								str += '<div class="adduser_div uls">';
								str += '<p class="addus" style="overflow: hidden;">';
								if (ret.ret.list[i].img == null || ret.ret.list[i].img == "null") {
									str += '<img src="' + picurl + '/redian-img-zan.png"style="width:100%;height:100%;"></p>';
								} else {
									str += '<img src="' + _img(ret.ret.list[i].img) + '"style="width:100%;height:100%;"></p>';
								}
								str += '<p>' + beautySub(ret.ret.list[i].nickname, 2) + '</p>';
								str += '<p>';
								if (ret.ret.list[i].levels == 0 && ret.ret.list[i].agent == 0) {
									str += "普通";
								} else if (ret.ret.list[i].agent == 1 && ret.ret.list[i].levels == 0) {
									str += "达人";
								} else if (ret.ret.list[i].agent == 1 && ret.ret.list[i].levels == 1) {
									str += "工会";
								} else if (ret.ret.list[i].agent == 1 && ret.ret.list[i].levels == 2) {
									str += "机构";
								}
								str += '</p>';
								str += '</div>';
							}
							for (var j = 0; j < (10 - (ret.ret.list.length)); j++) {
								tpl += '<div class="adduser_div kols">';
								tpl += '<p class="addus"></p>';
								tpl += '<p>待添加</p>';
								tpl += '<p>达人</p>';
								tpl += '</div>';

							}
							str = str + tpl;
							$(".adduser_list").html(str);
						} else {
							var tpl = '';
							for (var j = 0; j < 10; j++) {
								tpl += '<div class="adduser_div kols">';
								tpl += '<p class="addus"></p>';
								tpl += '<p>待添加</p>';
								tpl += '<p>达人</p>';
								tpl += '</div>';
							}
							$(".adduser_list").html(tpl);
						}
					}
				} else if (ret.ret.is_agent == "0" && ret.ret.levels == "2") {
					$(".cl").css("display", "block");
					$(".ajaxtet span").text("机构");
					$(".mla span").text("机构专属任务");
					$(".adduser_tit span").eq(0).text("机构成员");
					$(".adduser_tit span").eq(1).text("机构可以帮助二十名会员免费升为达人");
					$(".sjka").text("招募更多达人更多收益");
					$(".gh p").eq(2).css("width", "40%");
					$(".gh p").eq(2).css("text-align", "right");
					$(".tbnsj").css("display", "none");
					if (ret.ret.list) {
						if (ret.ret.list.length > 0 && ret.ret.list.length <= 20) {
							var str = '';
							var tpl = '';
							for (var i = 0; i < ret.ret.list.length; i++) {
								str += '<div class="adduser_div uls">';
								str += '<p class="addus" style="overflow: hidden;">';
								if (ret.ret.list[i].img == null || ret.ret.list[i].img == "null") {
									str += '<img src="' + picurl + '/redian-img-zan.png"style="width:100%;height:100%;"></p>';
								} else {
									str += '<img src="' + _img(ret.ret.list[i].img) + '"style="width:100%;height:100%;"></p>';
								}
								str += '<p>' + beautySub(ret.ret.list[i].nickname, 2) + '</p>';
								str += '<p>';
								if (ret.ret.list[i].levels == 0 && ret.ret.list[i].agent == 0) {
									str += "普通";
								} else if (ret.ret.list[i].agent == 1 && ret.ret.list[i].levels == 0) {
									str += "达人";
								} else if (ret.ret.list[i].agent == 1 && ret.ret.list[i].levels == 1) {
									str += "工会";
								} else if (ret.ret.list[i].agent == 1 && ret.ret.list[i].levels == 2) {
									str += "机构";
								}
								str += '</p>';
								str += '</div>';
							}
							for (var j = 0; j < (20 - (ret.ret.list.length)); j++) {
								tpl += '<div class="adduser_div kols">';
								tpl += '<p class="addus"></p>';
								tpl += '<p>待添加</p>';
								tpl += '<p>达人</p>';
								tpl += '</div>';
							}
							str = str + tpl;
							$(".adduser_list").html(str);
						} else {
							var tpl = '';
							for (var j = 0; j < 20; j++) {
								tpl += '<div class="adduser_div kols">';
								tpl += '<p class="addus"></p>';
								tpl += '<p>待添加</p>';
								tpl += '<p>达人</p>';
								tpl += '</div>';
							}
							$(".adduser_list").html(tpl);
						}
					}
				} else if (ret.ret.is_agent == "0" && ret.ret.levels == "1") {
					$(".cl").css("display", "block");
					$(".ajaxtet span").text("工会");
					$(".mla span").text("工会专属任务");
					$(".adduser_tit span").eq(0).text("工会成员");
					$(".adduser_tit span").eq(1).text("工会可以帮助五名会员免费升为达人");
					$(".sjka").text("招募更多达人更多收益");
					$(".gh p").eq(2).css("width", "40%");
					$(".gh p").eq(2).css("text-align", "right");
					$(".tbnsj").css("display", "none");
					if (ret.ret.list) {
						if (ret.ret.list.length > 0 && ret.ret.list.length <= 5) {
							var str = '';
							var tpl = '';
							for (var i = 0; i < ret.ret.list.length; i++) {
								str += '<div class="adduser_div uls">';
								str += '<p class="addus" style="overflow: hidden;">';
								if (ret.ret.list[i].img == null || ret.ret.list[i].img == "null") {
									str += '<img src="' + picurl + '/redian-img-zan.png"style="width:100%;height:100%;"></p>';
								} else {
									str += '<img src="' + _img(ret.ret.list[i].img) + '"style="width:100%;height:100%;"></p>';
								}
								str += '<p>' + beautySub(ret.ret.list[i].nickname, 2) + '</p>';
								str += '<p>';
								if (ret.ret.list[i].levels == 0 && ret.ret.list[i].agent == 0) {
									str += "普通";
								} else if (ret.ret.list[i].agent == 1 && ret.ret.list[i].levels == 0) {
									str += "达人";
								} else if (ret.ret.list[i].agent == 1 && ret.ret.list[i].levels == 1) {
									str += "工会";
								} else if (ret.ret.list[i].agent == 1 && ret.ret.list[i].levels == 2) {
									str += "机构";
								}
								str += '</p>';
								str += '</div>';
							}
							for (var j = 0; j < (5 - (ret.ret.list.length)); j++) {
								tpl += '<div class="adduser_div kols">';
								tpl += '<p class="addus"></p>';
								tpl += '<p>待添加</p>';
								tpl += '<p>达人</p>';
								tpl += '</div>';

							}
							str = str + tpl;
							$(".adduser_list").html(str);
						} else {
							var tpl = '';
							for (var j = 0; j < 5; j++) {
								tpl += '<div class="adduser_div kols">';
								tpl += '<p class="addus"></p>';
								tpl += '<p>待添加</p>';
								tpl += '<p>达人</p>';
								tpl += '</div>';
							}
							$(".adduser_list").html(tpl);
						}
					}
				}
			}
		})
		var money;
		var ids;
		var time;
		//线上升级
		$(".gh").on("click", ".tella", function() {
			_ajax1('agent/index', function(ret, err) {
				// console.log(JSON.stringify(ret));
				if (ret) {
					if (ret.ret.agent == 1 && ret.ret.levels == 0) {
						$(".tenkls").css("display", "block");
					} else if (ret.ret.agent == 1 && ret.ret.levels == 1) {
						$(".tle").css("display", "block");
						$(".mains p").css("display", "block");
						$(".mains p").eq(1).css("display", "none");
					}
				} else {
					// _alert('价格获取失败，请联系客服');
				}
			})
		})
		$(".close").on("click", function() {
			$(".tle").hide();
		})
		$(".payfsw").on("click", function() {
			var tex = $(this).children("span").eq(0).text();
			$(".payfsw").attr("name", "a");
			$(this).attr("name", "b");
			$(".payfsw").css("border", "1px solid #39393C")
			$(this).css("border", "1px solid #FF004F")
			$(".payfsw").children("span").css("color", "#39393C");
			$(this).children("span").css("color", "#FF004F");
			$(".payfsw").children("img").attr("src", "" + picurl + "/addpic/hei.png");
			$(this).children("img").attr("src", "" + picurl + "/addpic/reda.png");
			$(".payfsw").children("small").css("background", "#39393C");
			$(this).children("small").css("background", "#FF004F");
		})
		//关闭
		$(".closebtn").on("click", function() {
			$("body").css("overflow", "auto");
			$(".tcsja").css("display", "none");
		})
		//支付
		$(".btnsure").on("click", function() {
			var len = $(".payfsw[name=b]").length;
			if (len > 0) {
				var tex = $(".payfsw[name=b]").children("span").text();
				var type;
				if (tex == "工会") {
					type = 5;
				} else if (tex == "机构") {
					type = 6;
				}
				var money;
				var time;
				var id;
				// alert(type);
				_ajax('member/vip_money', function(ret, err) {
					// console.log(JSON.stringify(ret));
					if (ret) {
						$(".tcsja").css("display", "none");
						for (var i = 0; i < ret.length; i++) {
							if (ret[i].type == type) {
								money = ret[i].money;
								time = ret[i].time;
								id = ret[i].id;
								pay(money, id, time);
							}
						}
					} else {}
				})
			} else {
				_alert("请先选择!")
			}


		})

		function pay(money, id, time) {
			// alert(money+"/"+id+"/"+time)
			if (_getPrefs('_config').pay.alipay == 1 && _getPrefs('_config').pay.weixin == 1) {
				var buttons = ['支付宝', '微信'];
				var channel = ['ALI_APP', 'WX_APP'];
			} else if (_getPrefs('_config').pay.alipay == 1) {
				var buttons = ['支付宝'];
				var channel = ['ALI_APP']
			} else if (_getPrefs('_config').pay.weixin == 1) {
				var buttons = ['微信'];
				var channel = ['WX_APP']
			} else {
				return _msg('支付未开放，敬请期待！');
			}
			api.actionSheet({
				title: '选择支付方式',
				cancelTitle: '取消',
				buttons: buttons
			}, function(ret, err) {
				var index = ret.buttonIndex;
				var data = {};
				data.money = money * 100;
				data.type = 2;
				data.vip_pay_id = id;
				data.time = time;
				if (channel.length + 1 == index) {
					return _msg('支付取消');
				}
				data.channel = channel[index - 1];
				_pay(data);
			});
		}

		function pays(data) {
			return _msg('支付未开通配置 请在后台支付配置！');
			_loading('正在请求')
			_ajax('member/pay_code', function(ret, err) {
				_loadingCloes()
				if (ret) {
					if (ret.ret) {
						// 判断结束
						var payData = {
							title: '用户(ID' + _user.id + ')购买' + data.time + '天VIP特权',
							totalfee: data.money,
							billno: ret.ret,
							channel: data.channel,
							optional: {
								uid: _user.id,
								payname: '购买VIP',
								type: data.type,
								vip_pay_id: data.vip_pay_id
							}
						};
						beecloud.pay(payData, payCallBack);
						function payCallBack(ret, err) {
							_heibai();
							if (ret) {
								if (ret.result_code == 0) {
									if (ret.result_msg == '支付成功') {
										_loading();
										_ajax('member/info', function(ret, err) {
											_loadingCloes();
											if (ret) {
												_setPrefs('_user', ret);
												_ajax1("agent/index", function(ret, err) {
													if (ret) {
														if (ret.ret.levels == 0 || ret.ret.levels == "0") {
															$(".username span").eq(1).text("达人");
														} else if (ret.ret.levels == 1 || ret.ret.levels == "1") {
															$(".username span").eq(1).text("工会");
														} else if (ret.ret.levels == 2 || ret.ret.levels == "2") {
															$(".username span").eq(1).text("机构");
														}
													}
												})
											}
											_data();
											// var url = $(".pic[as=a]").index();

											// return _alert('恭喜成功购买' + data.time + '天VIP特权')
										})
									}
								} else if (ret.errMsg) {
									_alert(JSON.stringify(ret))
								} else {
									_msg(ret.result_msg)
								}
							} else {
								_alert(JSON.stringify(err))
							}
						}
					} else {
						_alert('ret.err:' + ret.err)
					}
				} else {
					_alert(JSON.stringify(err))
				}
			}, data)


		}

		// 字符串自动截取省略号
		function beautySub(str, len) {
			var reg = /[\u4e00-\u9fa5]/g, //专业匹配中文
				slice = str.substring(0, len),
				chineseCharNum = (~~(slice.match(reg) && slice.match(reg).length)),
				realen = slice.length * 2 - chineseCharNum;
			return str.substr(0, realen) + (realen < str.length ? "..." : "");
		}

	}
</script>
